#ifndef CMESH_H
#define CMESH_H

// STD
#include <vector>

// PROJECT
#include "cvertex.h"
#include "cedge.h"
#include "cface.h"
#include "QtOpenGL"
#include "qdebug.h"

class CMesh
{
public:
	CMesh();
	~CMesh();

	bool					LoadOBJ(const char *);
	bool					LoadOBJ(std::string);
	bool					SaveOBJ(char *);
	bool					SaveOBJ(std::string);
	void					makeCopyOf(CMesh *);
	void					computeNormals();
	void					computeEdges();
	void					pairEdges();
	void					checkVerticesNormals();

	void					paint(GLenum mode);
	void					paint_pick();

	void					displaySingularity();

	void					normalizeSize();

	bool					isBuilt();
	bool					doesEdgeExist(CVertex*, CVertex *);
        int					findIndOfVertex(CVertex*);
	CEdge *					getEdgeFromVertices(CVertex*, CVertex *);
        CEdge *                                 getTwinFromEdge(CEdge * edge);

	CVertex *				getVertexByPos(CPoint3f P);

	void					clearAllList();
	void					clearVertexList();
	void					clearEdgeList();
	void					clearFaceList();

        std::vector<CVertex*>           m_VertexList;
	std::vector<CEdge*>		m_EdgeList;
	std::vector<CFace*>		m_FaceList;

        bool					m_bBuilt;

protected:

	bool					m_bVerticesNormals;

};

#endif // CMESH_H
